package com.ihr360.payroll.dao;

import com.ihr360.payroll.model.dto.attendance.report.AttendanceMonthlyReport;
import com.ihr360.rest.reposity.SimpleRestReposity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import java.util.Collection;
import java.util.List;

@RepositoryRestResource
public interface AttendanceMonthlyReportRepository extends SimpleRestReposity<AttendanceMonthlyReport, Long> {
    /**
     * 获取员工月报
     *
     * @return
     */
    @Query(value = "select * from attendancemonthlyreport where companyId=:companyId and year=:year and month=:month and salaryPlanId=:salaryPlanId and staffId in :staffIds", nativeQuery = true)
    List<AttendanceMonthlyReport> findMonthlyReportOfStaffs(@Param(value = "companyId") String companyId, @Param(value = "year") int year, @Param(value = "month") int month, @Param(value = "salaryPlanId") Long salaryPlanId, @Param(value = "staffIds") Collection<String> staffIds);

    Page<AttendanceMonthlyReport> findByCompanyIdAndStaffInfoStaffIdInAndSummaryId(@Param(value = "companyId") String companyId, @Param(value = "staffIds") List<String> staffIds, @Param(value = "summaryId") Long summaryId, Pageable pageable);

    Page<AttendanceMonthlyReport> findByCompanyIdAndSummaryId(String companyId, Long summaryId, Pageable pageable);

    List<AttendanceMonthlyReport> findByCompanyIdAndSummaryId(String companyId, Long summaryId);

    AttendanceMonthlyReport findByCompanyIdAndSummaryIdAndStaffInfoStaffId(String companyId, Long summaryId, String staffId);

}